package com.kk.init;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Constructor;

/**
 * 5. 智能实例化感知Bean后处理器
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2023-08-04
 */
@Slf4j
@Component
public class TestSmartInstantiationAwareBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor {
    @Override
    public Class<?> predictBeanType(Class<?> beanClass, String beanName) throws BeansException {
//        log.info("5.1 智能实例化感知Bean后处理器 predictBeanType " + beanName);
        return beanClass;
    }

    @Override
    public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
        log.info("5.2 智能实例化感知Bean后处理器 determineCandidateConstructors " + beanName + " "+ beanClass);
        return null;
    }

    @Override
    public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
        log.info("5.3 智能实例化感知Bean后处理器 getEarlyBeanReference " + beanName);
        return bean;
    }
}
